package agent.strategy;

import oracle.MoveTypes;

/**
 * This is the greedy strategy that doesn't value future information
 * It is used to find the optimal strategy for the current run if there are no explore
 * actions taken account of, if the board is not explored, it might be worth exploring in
 * the middle of using this strategy
 * @author mdailey
 *
 */
public class GreedyStrategy extends Strategy {

	public GreedyStrategy(BoardMemory myBoard) {
		super(myBoard);
	}
	
	
	/**
	 * This is the greedy agent that does the best possible move
	 * according to one of the representations of the board
	 * @param commitTime How many moves are we looking ahead
	 * @param 
	 * @param FLAG  1-use accurateBoard, 2-pessimisticBoard, 3-optimisticBoard
	 */
	public nextDirObject nextMove(double commitTime, double param2, double FLAG){
		setUpFields();

		this.commitTime = (int) commitTime;
		nextDirObject myMove = null;
		if(FLAG == 2)
			myMove = getMaxUtil(this.pessimisticBoard, this.currRow, this.currColumn);
		else if(FLAG == 3)
			myMove = getMaxUtil(this.goodBoard, this.currRow, this.currColumn);
		else
			myMove = getMaxUtil(this.theBoard, this.currRow, this.currColumn);
		System.out.println("-----------" + myMove.toString());
	/*	if(FLAG == 1 && (this.penaltyDeath + 5 > myMove.expectedUtility) )
			myMove.moveDirection = MoveTypes.KILL_SELF;*/
		myMove.adviseMove = true;	// always advice move
		return myMove;
	}

	/**
	 * This returns the maximum utility of what we should do from our square
	 * It uses an accurate penalty of death
	 * @param row
	 * @param col
	 * @return
	 */
	public nextDirObject getMaxUtil(double[][] board, int row, int col){
		return getNextDirection(board, terminals, walls, null, null, row, col,
				(int)Math.min(this.commitTime,this.numMovesRemaining), this.penaltyDeath, this.maxRow, this.maxCol,
				this.numRoundsRemaining,0);
	}
}
